/*******************************************************************************
 * Copyright (c) 2011 squid.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     squid - initial API and implementation
 ******************************************************************************/
package com.google.code.cubeirc.connection.listeners;

import org.apache.log4j.Level;
import org.pircbotx.hooks.ListenerAdapter;
import org.pircbotx.hooks.events.ConnectEvent;
import org.pircbotx.hooks.events.DisconnectEvent;

import com.google.code.cubeirc.connection.CubeIRC;
import com.google.code.cubeirc.debug.DebuggerQueue;
import com.google.code.cubeirc.queue.MessageQueue;
import com.google.code.cubeirc.queue.MessageQueueEnum;

public class ConnectListener extends ListenerAdapter<CubeIRC> {
	@Override
	public void onConnect(ConnectEvent<CubeIRC> event) throws Exception {
		DebuggerQueue.addDebug(this, Level.INFO, "Connected to server");
		MessageQueue.addQueue(MessageQueueEnum.IRC_CONNECTED, event.getBot().getServerInfo());
		super.onConnect(event);
	}
	
	@Override
	public void onDisconnect(DisconnectEvent<CubeIRC> event) throws Exception {
		DebuggerQueue.addDebug(this, Level.INFO, "Disconnected from server");
		MessageQueue.addQueue(MessageQueueEnum.IRC_DISCONNECTED, event.getBot().getServerInfo());
		super.onDisconnect(event);
	}

}
